﻿using System;
using System.Drawing.Drawing2D;
using Autodesk.Revit.DB;
using YArchitech.Revit.RevitExtension;
using StairsModuleAndEdit.StairsModel.CommonUnit;

namespace StairsModuleAndEdit.StairsModel.DataInfos
{
	public struct CurveInfo
	{
		public Curve CurveObj
		{
			get
			{
				return this.m_Curve;
			}
			set
			{
				this.m_Curve = value;
			}
		}

		public PenColor Color
		{
			get
			{
				return this.m_Color;
			}
			set
			{
				this.m_Color = value;
			}
		}

		public DashStyle CurveDashStyle
		{
			get
			{
				return this.m_DashStyle;
			}
			set
			{
				this.m_DashStyle = value;
			}
		}

		public float LineWidth
		{
			get
			{
				return this.m_LineWidth;
			}
			set
			{
				this.m_LineWidth = value;
			}
		}

		public XYZ Normal
		{
			get
			{
				return this.m_Normal;
			}
			set
			{
				this.m_Normal = value;
			}
		}

		public CurveInfo(CurveInfo rhs)
		{
			this.m_Curve = rhs.CurveObj;
			this.m_Color = rhs.Color;
			this.m_DashStyle = rhs.m_DashStyle;
			this.m_LineWidth = rhs.m_LineWidth;
			this.m_Normal = XYZ.Zero;
		}

		public CurveInfo(Curve curve, PenColor color, float lineWidth)
		{
			this.m_Curve = curve;
			this.m_Color = color;
			this.m_DashStyle = DashStyle.Solid;
			this.m_LineWidth = lineWidth;
			this.m_Normal = XYZ.Zero;
		}

		public CurveInfo(Curve curve, PenColor color, DashStyle dashStyle, float lineWidth)
		{
			this.m_Curve = curve;
			this.m_Color = color;
			this.m_DashStyle = dashStyle;
			this.m_LineWidth = lineWidth;
			this.m_Normal = XYZ.Zero;
		}

		public CurveInfo LineTransformTo(Transform matrix)
		{
			XYZ xyz = this.m_Curve.GetEndPoint(0);
			XYZ xyz2 = this.m_Curve.GetEndPoint(1);
			xyz = Geometry.TransformPoint(xyz, matrix);
			xyz2 = Geometry.TransformPoint(xyz2, matrix);
			Line curve = null;
			CurveInfo result;
			try
			{
				curve = YJKLineEx.YJKGetBound(xyz, xyz2);
				result = new CurveInfo(curve, this.m_Color, this.m_DashStyle, this.m_LineWidth);
			}
			catch (Exception)
			{
				result = new CurveInfo(curve, this.m_Color, this.m_DashStyle, this.m_LineWidth);
			}
			return result;
		}

		private Curve m_Curve;

		private PenColor m_Color;

		private DashStyle m_DashStyle;

		private float m_LineWidth;

		private XYZ m_Normal;
	}
}
